<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
    <TITLE>Class Template chain</TITLE>
    <LINK REL="stylesheet" HREF="../../../../boost.css">
    <LINK REL="stylesheet" HREF="../theme/iostreams.css">
</HEAD>
<BODY>

<!-- Begin Banner -->

    <H1 CLASS="title">Function Template <CODE>compose</CODE></H1>
    <HR CLASS="banner">

<!-- End Banner -->

<DL class="page-index">
  <DT><A href="#description">Description</A></DT>
  <DT><A href="#headers">Headers</A></DT>
  <DT><A href="#reference">Reference</A></DT>
</DL>

<HR>

<A NAME="description"></A>
<H2>Description</H2>

<P>
    Given a Filter <CODE>f</CODE> and a Device <CODE>d</CODE>, we may construct a device <CODE>c</CODE> whose member functions are implemented by invoking the fundamental i/o operations <A HREF='../functions/read.html'><CODE>read</CODE></A>, <A HREF='../functions/write.html'><CODE>write</CODE></A>, <I>etc.</I> with <CODE>f</CODE> as the first argument and <CODE>d</CODE> as the second. Similarly, if we are given two filters <CODE>f1</CODE> and <CODE>f2</CODE>, we may construct a third filter <CODE>f3</CODE> whose member function templates are implemented by invoking the fundamental i/o operations <A HREF='../functions/read.html'><CODE>read</CODE></A>, <A HREF='../functions/write.html'><CODE>write</CODE></A>, <I>etc.</I>, with first argument equal to <CODE>f1</CODE> and second argument equal to the result of composing <CODE>f2</CODE> with the provided Device.
</P>

<P>
    The function template <A HREF='#composite'><CODE>composite</CODE></A> represents a Filter or Device which has been constructed in the above manner. The function template <A HREF='#compose'><CODE>compose</CODE></A> is an <A HREF='http://www.boost.org/more/generic_programming.html#object_generator' TARGET='_top'>object generator</A> which given a pair of components returns an appropriate instance of <CODE>composite</CODE>.
</P>

<P>
    The <A HREF='../guide/modes.html'>mode</A> of a <CODE>composite</CODE> is defined to provide a maximal subset of the common functionality of the two components. A <CODE>composite</CODE> is <A HREF='../concepts/closable.html'>Closable</A>, <A HREF='../concepts/flushable.html'>Flushable</A>, <A HREF='../concepts/localizable.html'>Localizable</A> and <A HREF='../concepts/optimally_buffered.html'>OptimallyBuffered</A>.
</P>

<A NAME="headers"></A>
<H2>Headers</H2>

<DL class="page-index">
  <DT><A CLASS="header" HREF="../../../../boost/iostreams/compose.hpp"><CODE>&lt;boost/iostreams/compose.hpp&gt;</CODE></A></DT>
</DL>

<A NAME="reference"></A>
<H2>Reference</H2>

<A NAME="synopsis"></A>
<H4>Synopsis</H4>

<PRE CLASS="broken_ie"><SPAN CLASS="keyword">namespace</SPAN> boost { <SPAN CLASS="keyword">namespace</SPAN> iostreams {

<SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#composite_template_params">Filter</A>, <SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#composite_template_params">FilterOrDevice</A>&gt;
<SPAN CLASS='keyword'>class</SPAN> <A CLASS='documented' HREF='#composite'>composite</A> {
<SPAN CLASS='keyword'>public:</SPAN>
    <SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='keyword'>typename</SPAN> <A CLASS='documented' HREF='../guide/traits.html#char_type'>char_type_of</A>&lt;Filter&gt;::type  char_type;
    <SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>implementation-defined</SPAN>               mode;

    <A CLASS='documented' HREF='#composite_ctor'>composite</A>(<SPAN CLASS='keyword'>const</SPAN> Filter&amp; first, [<SPAN CLASS='keyword'>const</SPAN>] FilterOrDevice&amp; second);

    <SPAN CLASS='comment'>// Filter or Device member functions</SPAN>
};

<SPAN CLASS="keyword">template</SPAN>&lt;<SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#compose_template_params">Filter</A>, <SPAN CLASS="keyword">typename</SPAN> <A CLASS="documented" HREF="#compose_template_params">FilterOrDevice</A>&gt;
<A CLASS='documented' HREF='#composite'>composite</A>&lt;Filter, FilterOrDevice&gt; 
<A CLASS='documented' HREF='#compose'>compose</A>(<SPAN CLASS='keyword'>const</SPAN> Filter&amp; first, [<SPAN CLASS='keyword'>const</SPAN>] FilterOrDevice&amp; second);

} } // End namespace boost::io</PRE>

<A NAME="composite"></A>
<H2>Class Template <CODE>composite</CODE></H2>

<A NAME="composite_template_params"></A>
<H4>Template parameters</H4>

<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
<TR>
    <TR>
        <TD VALIGN="top"><I>Filter</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
        <TD>A model of <A HREF='../concepts/filter.html'>Filter</A></TD>
    </TR>
    <TR>
        <TD VALIGN="top"><I>FilterOrDevice</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
        <TD>A model of <A HREF='../concepts/filter.html'>Filter</A> or <A HREF='../concepts/device.html'>Device</A></TD>
    </TR>
</TABLE>

<A NAME="composite_ctor"></A>
<H4><CODE>composite::composite</CODE></H4>

<PRE CLASS="broken_ie">    composite(<SPAN CLASS='keyword'>const</SPAN> Filter&amp; first, [<SPAN CLASS='keyword'>const</SPAN>] FilterOrDevice&amp; second);</PRE>

<P>
    Constructs an instance of <CODE>composite</CODE> based on the given components. If <CODE>FilterOrDevice</CODE> is a stream or stream buffer type, the second parameter is a non-<CODE>const</CODE> reference; otherwise it is a <CODE>const</CODE> reference.
</P>

<A NAME="compose"></A>
<H2>Function Template <CODE>compose</CODE></H2>

<PRE CLASS="broken_ie">    composite(<SPAN CLASS='keyword'>const</SPAN> Filter&amp; first, [<SPAN CLASS='keyword'>const</SPAN>] FilterOrDevice&amp; second);</PRE>

<A NAME="compose_template_params"></A>
<H4>Template parameters</H4>

<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
<TR>
    <TR>
        <TD VALIGN="top"><I>Filter</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
        <TD>A model of <A HREF='../concepts/filter.html'>Filter</A></TD>
    </TR>
    <TR>
        <TD VALIGN="top"><I>FilterOrDevice</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
        <TD>A model of <A HREF='../concepts/filter.html'>Filter</A> or <A HREF='../concepts/device.html'>Device</A></TD>
    </TR>
</TABLE>

<P>
    Returns an instance of an appropriate specialization of <CODE>composite</CODE> constructed from the given components. If <CODE>FilterOrDevice</CODE> is a stream or stream buffer type, the second parameter is a non-<CODE>const</CODE> reference; otherwise it is a <CODE>const</CODE> reference.
</P>

<!-- Begin Footer -->

<HR>

<P CLASS="copyright">&copy; Copyright 2008 <a href="http://www.coderage.com/" target="_top">CodeRage, LLC</a><br/>&copy; Copyright 2004-2007 <a href="https://www.boost.org/users/people/jonathan_turkanis.html" target="_top">Jonathan Turkanis</a></P>
<P CLASS="copyright"> 
    Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <A HREF="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)
</P>

<!-- End Footer -->

</BODY>
